import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * 
 */

/**
 * @author zhongfang
 *
 */
public class 网易2 {

	static class QiZi{
		int index;
		int[] pos=new int[2];
		Integer[] nearNeibs;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();
		QiZi allQizi[]=new QiZi[n];
		int d[][]=new int[n][n];//任意两点的距离
		Integer nearestNeibs[][]=new Integer[n][n];
		for (int i = 0; i < n; i++) {//输入位置
//			A[i][0]=scanner.nextInt();
//			A[i][1]=scanner.nextInt();
			QiZi qiZi=new QiZi();
			qiZi.index=i;
			qiZi.pos[0]=scanner.nextInt();
			qiZi.pos[1]=scanner.nextInt();
			allQizi[i]=qiZi;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < i; j++) {
				d[i][j]=Math.abs(allQizi[i].pos[0]-allQizi[j].pos[0])+Math.abs(allQizi[i].pos[1]-allQizi[j].pos[1]);
				d[j][i]=d[i][j];
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				allQizi[i].nearNeibs[j]=j;
			}
		}
		for (int i = 0; i < nearestNeibs.length; i++) {
			final int s=i;
			Arrays.sort(allQizi[i].nearNeibs,new Comparator<Integer>() {
				@Override
				public int compare(Integer o1, Integer o2) {
					return d[s][o2]-d[s][o1];
				}
			});
		}
		for (int i = 0; i < n; i++) {//i个棋子在一个格子
			for (int j = 0; j < n; j++) {
				
			}
		}
	}
}
